/* DATA PREPERATION */
/* Merge the data */
use "/Users/scottmcclurg/Dropbox/In Progress/Cross-National Gender/Replication and SI Material/cross-national variables.dta"
sort isspid
save, replace
use "/Users/scottmcclurg/Dropbox/In Progress/Cross-National Gender/Replication and SI Material/individual variables.dta"
sort isspid
merge m:1 isspid using "/Users/scottmcclurg/Dropbox/In Progress/Cross-National Gender/Replication and SI Material/cross-national variables.dta"
drop _merge
drop if isspid==15
drop if isspid==18
drop if isspid==34
drop if isspid==36
drop if isspid==39
save "/Users/scottmcclurg/Dropbox/In Progress/Cross-National Gender/Replication and SI Material/discuss2014.dta", replace

/* Create interaction terms */
gen ies =female*es
gen imandquota =female*mandquota
gen ifemvote =female*femvote
gen ipctfem = female*pctfemparl
gen iincome =female*incomegap
gen ieducgap =female*educgap
gen iincomegap =female*incomegap
gen iemploygap =female*employgap
gen ilag1 =female*pctlag1
gen ilag5 =female*pctlag5
gen ilag10 =female*pctlag10
gen icosmo =female*cosmo
gen ireligioncat =female*religioncat
gen isexequal =female*sexequal
gen idisprop =female*disprop


/* PAPER */
/* Table 1 */
sum talkscale female age logincome educ interest es mandquota femvote pctfemparl educgap incomegap employgap

/* Table 2 */
xtmixed talkscale female age logincome educ interest es ies || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest mandquota imandquota || isspid: , cov(un)

/* Table 3 */
xtmixed talkscale female age logincome educ interest femvote ifemvote || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest pctfemparl ipctfem || isspid: , cov(un)

/* Table 4 */
xtmixed talkscale female age logincome educ interest educgap ieducgap || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest incomegap iincomegap || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest employgap iemploygap || isspid: , cov(un)

/* Table 5 */
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota femvote ifemvote pctfemparl ipctfem employgap iemploygap || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem  || isspid: , cov(un)

/* Margins for Figure 2 */
xtmixed talkscale i.female age logincome educ interest i.es i.es#i.female i.mandquota i.mandquota#i.female c.pctfem c.pctfem#i.female  || isspid: , cov(un)
margins, dydx(female) at(es=(0 1 2))
margins, dydx(female) at(mand=(0 1))
margins, dydx(female) at(pctfemparl=(5(5)50))



/* SUPPLEMENTARY INFORMATION */
/* gllamm specifications */
gen one=1
eq g_cons: one

/* Table A */
gllamm poldisc female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem , i(isspid) family(binomial) link(ologit) nrf(1) eqs(g_cons) adapt
gllamm persuade female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem , i(isspid) family(binomial) link(ologit) nrf(1) eqs(g_cons) adapt

/* Table B */
xtmixed talkscale female age logincome educ interest pctlag1 ilag1 || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest pctlag5 ilag5 || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest pctlag10 ilag10 || isspid: , cov(un)

/* Table C */
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem cosmo religioncat sexequal  || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem cosmo icosmo religioncat ireligioncat sexequal isexequal || isspid: , cov(un)

/* Table D */
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem cosmo icosmo  || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem religioncat ireligioncat || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem sexequal isexequal || isspid: , cov(un)

/* Table E */
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem if ksb==1 || isspid: , cov(un)

/* Table F */
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem disprop idisprop || isspid: , cov(un)
xtmixed talkscale female age logincome educ interest mandquota imandquota pctfemparl ipctfem disprop idisprop || isspid: , cov(un)

/* Table G */
xtmixed talkscale female age logincome educ interest es ies mandquota imandquota pctfemparl ipctfem  || isspid: female, cov(un)



/* COMMANDS FOR FIGURE 2 */
use poqRRfig2.dta
twoway (scatter Coefficient es, mcolor(black) msize(medium) msymbol(circle)) (rcap ll ul es, lcolor(black) lpattern(solid)) (line yline es, lcolor(gs12) lpattern(dash)) if mand==. & pctfem==., ytitle("Effect of Being a Female") ytitle(, size(medsmall) color(black)) ylabel(-.20(.05)0.0) xlabel(0 "Majoritarian" 1 "Mixed" 2 "PR") legend(order(1 "Coefficient" 2 "95% c.i.")) name(es, replace) aspectratio(1)
twoway (scatter Coefficient mandquota, mcolor(black) msize(medium) msymbol(circle)) (rcap ll ul mandquota, lcolor(black) lpattern(solid)) (line yline mandquota, lcolor(gs12) lpattern(dash)) if es==. & pctfem==., ytitle("Effect of Being a Female") ytitle(, size(medsmall) color(black)) ylabel(-.20(.05)0.0) xlabel(0 "No Quota" 1 "Quota") legend(order(1 "Coefficient" 2 "95% c.i.")) name(mand, replace) aspectratio(1)
twoway (scatter Coefficient pctfemparl, mcolor(black) msize(medium) msymbol(circle)) (rcap ll ul pctfemparl, lcolor(black) lpattern(solid)) (line yline pctfemparl, lcolor(gs12) lpattern(dash)) if es==. & mand==., ytitle("Effect of Being a Female") ytitle(, size(medsmall) color(black)) ylabel(-.20(.05)0.0) xlabel(5(5)50, labsize(small)) legend(order(1 "Coefficient" 2 "95% c.i.")) name(pct, replace) aspectratio(1)
graph combine es mand pct, ycommon name(poqRRfig2, replace)

